from model_average.Alex_like_96 import Alex_like_predict_noAug_96
from model_average.VGG_like_64 import VGG_like_predict_noAug_64
from model_average.VGG_like_64_aug import VGG_like_predict_Aug_64
from model_average.Alex_like_96_aug import Alex_like_predict_Aug_96
from model_average.VGG_like_70 import VGG_like_predict_noAug_70
from model_average.VGG_like_70_aug import VGG_like_predict_Aug_70
import numpy as np
import csv

def test_average():
    names_64_UFS, Pred_64_UFS = VGG_like_predict_noAug_64()
    namws_96_UFS, Pred_96_UFS = Alex_like_predict_noAug_96()

    average_Pred = (Pred_96_UFS + Pred_64_UFS)
    for i in range(len(average_Pred)):
        index= np.argmax(average_Pred[i])
        print index


def average_2models_noAug():
    names_64_UFS, Pred_64_UFS = VGG_like_predict_noAug_64()
    namws_96_UFS, Pred_96_UFS = Alex_like_predict_noAug_96()

    indexs = []
    average_Pred = (Pred_96_UFS + Pred_64_UFS)
    for i in range(len(average_Pred)):
        index = np.argmax(average_Pred[i])
        indexs.append(index)

    answerFile = '/home/dell/wxm/Code/JD/log_records/submit/model_average/Two/Aver_64_96_noAug_UFS.csv'
    f = file(answerFile,'wb')
    csvwriter = csv.writer(f)
    for i in range(len(average_Pred)):
        answer = [names_64_UFS[i] , str(indexs[i])]
        csvwriter.writerow(answer)

def average_3models():
    names_64_UFS, Pred_64_UFS = VGG_like_predict_noAug_64()
    names_96_UFS, Pred_96_UFS = Alex_like_predict_noAug_96()
    names_64_UFS_aug, Pred_64_UFS_aug = VGG_like_predict_Aug_64()

    indexs = []
    average_Pred = (Pred_96_UFS + Pred_64_UFS + Pred_64_UFS_aug)
    for i in range(len(average_Pred)):
        index = np.argmax(average_Pred[i])
        indexs.append(index)

    answerFile = '/home/dell/wxm/Code/JD/answer/Aver3_FS_W.csv'
    f = file(answerFile,'wb')
    csvwriter = csv.writer(f)
    for i in range(len(average_Pred)):
        answer = [names_64_UFS[i] , str(indexs[i])]
        csvwriter.writerow(answer)

def average_4models():
    names_64, Pred_64 = VGG_like_predict_noAug_64()
    names_96, Pred_96 = Alex_like_predict_noAug_96()
    names_64_aug, Pred_64_aug = VGG_like_predict_Aug_64()
    names_70, Pred_70 = VGG_like_predict_Aug_70()
    indexs = []
    average_Pred = (Pred_64 + Pred_64_aug + Pred_96 + Pred_70)
    for i in range(len(average_Pred)):
        index = np.argmax(average_Pred[i])
        indexs.append(index)

    answerFile = '/home/dell/wxm/Code/JD/answer/Aver4_Aug70.csv'
    f = file(answerFile,'wb')
    csvwriter = csv.writer(f)
    for i in range(len(average_Pred)):
        answer = [names_64[i] , str(indexs[i])]
        csvwriter.writerow(answer)

def average_6models():
    names_64, Pred_64 = VGG_like_predict_noAug_64()
    names_96, Pred_96 = Alex_like_predict_noAug_96()
    names_70, Pred_70 = VGG_like_predict_noAug_70()
    names_64_aug, Pred_64_aug = VGG_like_predict_Aug_64()
    names_96_aug, Pred_96_aug = Alex_like_predict_Aug_96()
    names_70_aug , Pred_70_aug = VGG_like_predict_Aug_70()
    indexs = []
    average_Pred = (Pred_64 + Pred_64_aug + Pred_96 + Pred_70 + Pred_70_aug + Pred_96_aug)
    for i in range(len(average_Pred)):
        index = np.argmax(average_Pred[i])
        indexs.append(index)

    answerFile = '/home/dell/wxm/Code/JD/answer/Aver6.csv'
    f = file(answerFile,'wb')
    csvwriter = csv.writer(f)
    for i in range(len(average_Pred)):
        answer = [names_64[i] , str(indexs[i])]
        csvwriter.writerow(answer)

if __name__ == '__main__':
    average_6models()